//
// Created by 张兮兮 on 2025/3/11.
//

#ifndef TEMP_YOLOSOCKETWIDGET_H
#define TEMP_YOLOSOCKETWIDGET_H

//extern "C"
//{
//#include "libavutil/time.h"
//}

#include "Python.h"
#include <QWidget>
#include <QTimer>
#include <QPainter>
#include <QBuffer>
//#include "ColorRect.h"
#include <QLocalSocket>
#include <QElapsedTimer>
class YoloSocketWidget : public QWidget {
Q_OBJECT
public:
    YoloSocketWidget(QWidget *parent = nullptr);

    ~YoloSocketWidget();

protected:
    void paintEvent(QPaintEvent *event) override;

private:
    void sendImage();

    void refresh();
private slots:


//void tryConnect();
    void readData();
    void handleProcessOutput();

private:
    bool isConnected = false;
    QString socketPath;
    QElapsedTimer timer;
    //进程连接
    QLocalSocket *socket;
    QElapsedTimer elapsedTimer;

    QList<QPoint> positions;
    QList<bool> upFingers;
//    int width = 1280;
//    int height = 720;
    QImage canvas;
    QPointF lastPoint;
//    int width = 375;
//    int height = 667;
    PyObject *pModule;
    PyObject *pFunc;
    QImage image;
    QTimer *timer11111;
//    std::vector<ColorRect> colors;
    int px = 0;
    int py = 0;
    int brushSize = 5;
    int eraserSize = 20;
    QColor color = QColor(Qt::red);

    QPixmap transparent;
};

#endif //TEMP_YOLOSOCKETWIDGET_H
